package com.flyway.utils;/**
 * @Author: xupx
 * @Date: 2019/11/15
 */

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.flyway.pojo.Users;

/**
 * @program: flyway->TokenUtils
 * @description: token处理类
 * @author: xupx
 * @create: 2019-11-15 10:32
 **/
public class TokenUtils {

    public static String getToken(Users user) {
        String token= JWT.create().withAudience(user.getUserId().toString())
                .sign(Algorithm.HMAC256(user.getPassword()));
        return token;
    }
    public static void checkToken(String passWord,String token) {
        JWT.require(Algorithm.HMAC256(passWord)).build().verify(token);
    }
}
